<?php
namespace View;

class DateView {


    /**
    * @return string HTML
    */
	public static function getCorrectDate() {

		//Skapar ett datum
		$today = getdate();

		//Kollar veckodag
		if ($today["wday"] == "1") {$wday="Monday";}
		else if ($today["wday"] == "2") {$wday="Tuesday";}
		else if ($today["wday"] == "3") {$wday="Wednesday";}
		else if ($today["wday"] == "4") {$wday="Thursday";}
		else if ($today["wday"] == "5") {$wday="Friday";}
		else if ($today["wday"] == "6") {$wday="Saturday";}
		else if ($today["wday"] == "0") {$wday="Sunday";}

		//Kolla Månad och lägger rätt månad i en variabel
		if ($today["mon"] == "1") { $mon="Januari";}
		else if ($today["mon"] == "2") { $mon="Februari";}
		else if ($today["mon"] == "3") { $mon="Mars";}
		else if ($today["mon"] == "4") { $mon="April";}
		else if ($today["mon"] == "5") { $mon="May";}
		else if ($today["mon"] == "6") { $mon="June";}
		else if ($today["mon"] == "7") { $mon="Juli";}
		else if ($today["mon"] == "8") { $mon="August";}
		else if ($today["mon"] == "9") { $mon="September";}
		else if ($today["mon"] == "10") {$mon="October";}
		else if ($today["mon"] == "11") {$mon="November";}
		else if ($today["mon"] == "12") {$mon="December";}

		//Rättar Timmarna genom att lägga till en 0:a framför < 10
		if ($today["hours"] < "10") {
			$i = $today["hours"];
			$hour="0" . $i;
		} else {
			$hour=$today["hours"];
		}

		//Rättar Minuterna genom att lägga till en 0:a framför < 10
		if ($today["minutes"] < "10") {
			$i = $today["minutes"];
			$min="0" . $i;
		} else {
			$min=$today["minutes"];
		}

		//Rättar Sekunderna genom att lägga till en 0:a framför < 10
		if ($today["seconds"] < "10") {
			$i = $today["seconds"];
			$sec="0" . $i;
		} else {
			$sec=$today["seconds"];
		}

        if ($today["mday"] == 1) {

            $y= "st";
        } else if ($today["mday"] == 2) {

            $y= "nd";
        }else {

           $y= "th";
        }

		$date = $wday . ", ".  $today["mday"] . $y . " " . $mon . " " . $today["year"] ." ". $hour . ":". $min. ":" . $sec  ;
		return $date;
	}


}

